package com.kqb.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.kqb.common.domain.page.PageResult;
import com.kqb.mapper.ForwarderInquiryProductMapper;
import com.kqb.pojo.ForwarderInquiryList;
import com.kqb.pojo.ForwarderInquiryProduct;
import com.kqb.service.ForwarderInquiryProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class ForwarderInquiryProductServiceImpl implements ForwarderInquiryProductService {

    @Autowired
    ForwarderInquiryProductMapper inquiryProductMapper;

    @Override
    public PageResult queryByMap(Map map) {
        int page=1;//当前第几页
        int pageSize=10;//默认每页记录数
        if(map.containsKey("page")){
            page=Integer.parseInt(map.get("page").toString());
        }
        if(map.containsKey("pageSize")){
            pageSize=Integer.parseInt(map.get("pageSize").toString());
        }
        PageHelper.startPage(page,pageSize);
        List list=inquiryProductMapper.queryByMap(map);
        PageInfo info=new PageInfo(list);
        return new PageResult(page,pageSize,info.getTotal(),list);
    }

    @Override
    public List<ForwarderInquiryProduct> queryByCode(String code) {
        return inquiryProductMapper.queryByCode(code);
    }
}
